package thread;
/**
 * 查看线程相关信息的一组方法
 */
public class ThreadInfoDemo {
    public static void main(String[] args) {
        //获取主线程
        Thread thread = Thread.currentThread();
        //获取线程名字
        String name = thread.getName();
        System.out.println(name);

        //获取线程的唯一标识
        long id = thread.getId();
        System.out.println(id);

        //获取线程的优先级(是一个数字，范围1-10之间)
        int priority = thread.getPriority();
        System.out.println("优先级"+priority);

        //查看是否为守护线程
        boolean daemon = thread.isDaemon();

        //查看是否活着
        boolean alive = thread.isAlive();

        //查看是否被中断了
        boolean interrupted = thread.isInterrupted();
        System.out.println("是否为守护线程"+daemon);
        System.out.println("是否活着"+alive);
        System.out.println("是否被中断"+interrupted);
    }
}
